<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 6.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha256-CTSx/A06dm1B063156EVh15m6Y67pAjZZaQc89LLSrU=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.24/fancybox/fancybox.css" integrity="sha256-vQkngPS8jiHHH0I6ABTZroZk8NPZ7b+MUReOFE9UsXQ=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"rjyblog.gitee.io","root":"/","images":"/images","scheme":"Pisces","darkmode":false,"version":"8.18.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":null},"fold":{"enable":false,"height":500},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="ViewGroupRecyclerViewScrollingViewRecyclerArrayList&lt;ViewHolder&gt; mAttachedScrapArrayList&lt;ViewHolder&gt; mChangedScrapArrayList&lt;ViewHolder&gt; mCachedViewsRecycledViewPool mRecyclerPoolRecyc">
<meta property="og:type" content="article">
<meta property="og:title" content="图解RecyclerView缓存机制">
<meta property="og:url" content="https://rjyblog.gitee.io/posts/e679f521.html">
<meta property="og:site_name" content="任建勇的博客">
<meta property="og:description" content="ViewGroupRecyclerViewScrollingViewRecyclerArrayList&lt;ViewHolder&gt; mAttachedScrapArrayList&lt;ViewHolder&gt; mChangedScrapArrayList&lt;ViewHolder&gt; mCachedViewsRecycledViewPool mRecyclerPoolRecyc">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://rjyblog.gitee.io/images/RecyclerView/remove_item.drawio.svg">
<meta property="og:image" content="https://rjyblog.gitee.io/images/RecyclerView/remove_item_cache_use_sequence.drawio.svg">
<meta property="og:image" content="https://rjyblog.gitee.io/images/RecyclerView/change_item_text.drawio.svg">
<meta property="og:image" content="https://rjyblog.gitee.io/images/RecyclerView/change_item_sequence.drawio.svg">
<meta property="og:image" content="https://rjyblog.gitee.io/images/RecyclerView/insert_item.drawio.svg">
<meta property="og:image" content="https://rjyblog.gitee.io/images/RecyclerView/insert_item_sequence.drawio.svg">
<meta property="og:image" content="https://rjyblog.gitee.io/images/RecyclerView_mCachedViews.drawio.svg">
<meta property="og:image" content="https://rjyblog.gitee.io/images/RecyclerView/RecyclerView%E6%9F%A5%E6%89%BE%E7%BC%93%E5%AD%98%E6%B5%81%E7%A8%8B%E5%9B%BE.drawio.svg">
<meta property="article:published_time" content="2023-09-19T01:20:14.000Z">
<meta property="article:modified_time" content="2023-10-18T06:00:25.168Z">
<meta property="article:author" content="Jason">
<meta property="article:tag" content="Android">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://rjyblog.gitee.io/images/RecyclerView/remove_item.drawio.svg">


<link rel="canonical" href="https://rjyblog.gitee.io/posts/e679f521.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://rjyblog.gitee.io/posts/e679f521.html","path":"posts/e679f521.html","title":"图解RecyclerView缓存机制"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>图解RecyclerView缓存机制 | 任建勇的博客</title>
  








  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">任建勇的博客</p>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%88%A0%E9%99%A4View%E7%BC%93%E5%AD%98%E4%BD%BF%E7%94%A8%E5%9B%BE%E8%A7%A3"><span class="nav-text">删除View缓存使用图解</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BF%AE%E6%94%B9View%E7%BC%93%E5%AD%98%E4%BD%BF%E7%94%A8%E5%9B%BE%E8%A7%A3"><span class="nav-text">修改View缓存使用图解</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%8F%92%E5%85%A5View%E7%BC%93%E5%AD%98%E4%BD%BF%E7%94%A8%E5%9B%BE%E8%A7%A3"><span class="nav-text">插入View缓存使用图解</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E9%A2%84%E5%8A%A0%E8%BD%BD%E7%BC%93%E5%AD%98-mCachedViews"><span class="nav-text">预加载缓存 mCachedViews</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%BB%91%E5%8A%A8%E6%97%B6%E9%A2%84%E5%8A%A0%E8%BD%BD%E6%B5%81%E7%A8%8B"><span class="nav-text">滑动时预加载流程</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#mAttachedScrap"><span class="nav-text">mAttachedScrap</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BB%8E%E7%BC%93%E5%AD%98%E8%8E%B7%E5%8F%96ViewHolder"><span class="nav-text">从缓存获取ViewHolder</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#ItemAnimator"><span class="nav-text">ItemAnimator</span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Jason"
      src="/images/avatar.png">
  <p class="site-author-name" itemprop="name">Jason</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">66</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">13</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">23</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://rjyblog.gitee.io/posts/e679f521.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="Jason">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="任建勇的博客">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="图解RecyclerView缓存机制 | 任建勇的博客">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          图解RecyclerView缓存机制
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2023-09-19 09:20:14" itemprop="dateCreated datePublished" datetime="2023-09-19T09:20:14+08:00">2023-09-19</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">更新于</span>
      <time title="修改时间：2023-10-18 14:00:25" itemprop="dateModified" datetime="2023-10-18T14:00:25+08:00">2023-10-18</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Android/" itemprop="url" rel="index"><span itemprop="name">Android</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="451px" preserveAspectRatio="none" style="width:319px;height:451px;background:#FFFFFF;" version="1.1" viewBox="0 0 319 451" width="319px" zoomAndPan="magnify"><defs/><g><!--class ViewGroup--><g id="elem_ViewGroup"><rect fill="#F1F1F1" height="48" id="ViewGroup" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="110" x="27.5" y="7"/><ellipse cx="42.5" cy="23" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M44.8438,18.6719 C43.9063,18.2344 43.3125,18.0938 42.4375,18.0938 C39.8125,18.0938 37.8125,20.1719 37.8125,22.8906 L37.8125,24.0156 C37.8125,26.5938 39.9219,28.4844 42.8125,28.4844 C44.0313,28.4844 45.1875,28.1875 45.9375,27.6406 C46.5156,27.2344 46.8438,26.7813 46.8438,26.3906 C46.8438,25.9375 46.4531,25.5469 45.9844,25.5469 C45.7656,25.5469 45.5625,25.625 45.375,25.8125 C44.9219,26.2969 44.9219,26.2969 44.7344,26.3906 C44.3125,26.6563 43.625,26.7813 42.8594,26.7813 C40.8125,26.7813 39.5156,25.6875 39.5156,23.9844 L39.5156,22.8906 C39.5156,21.1094 40.7656,19.7969 42.5,19.7969 C43.0781,19.7969 43.6875,19.9531 44.1563,20.2031 C44.6406,20.4844 44.8125,20.7031 44.9063,21.1094 C44.9688,21.5156 45,21.6406 45.1406,21.7656 C45.2813,21.9063 45.5156,22.0156 45.7344,22.0156 C46,22.0156 46.2656,21.875 46.4375,21.6563 C46.5469,21.5 46.5781,21.3125 46.5781,20.8906 L46.5781,19.4688 C46.5781,19.0313 46.5625,18.9063 46.4688,18.75 C46.3125,18.4844 46.0313,18.3438 45.7344,18.3438 C45.4375,18.3438 45.2344,18.4375 45.0156,18.75 L44.8438,18.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="78" x="56.5" y="27.8467">ViewGroup</text><line style="stroke:#181818;stroke-width:0.5;" x1="28.5" x2="136.5" y1="39" y2="39"/><line style="stroke:#181818;stroke-width:0.5;" x1="28.5" x2="136.5" y1="47" y2="47"/></g><!--class RecyclerView--><g id="elem_RecyclerView"><rect fill="#F1F1F1" height="48" id="RecyclerView" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="128" x="95.5" y="115"/><ellipse cx="110.5" cy="131" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M112.8438,126.6719 C111.9063,126.2344 111.3125,126.0938 110.4375,126.0938 C107.8125,126.0938 105.8125,128.1719 105.8125,130.8906 L105.8125,132.0156 C105.8125,134.5938 107.9219,136.4844 110.8125,136.4844 C112.0313,136.4844 113.1875,136.1875 113.9375,135.6406 C114.5156,135.2344 114.8438,134.7813 114.8438,134.3906 C114.8438,133.9375 114.4531,133.5469 113.9844,133.5469 C113.7656,133.5469 113.5625,133.625 113.375,133.8125 C112.9219,134.2969 112.9219,134.2969 112.7344,134.3906 C112.3125,134.6563 111.625,134.7813 110.8594,134.7813 C108.8125,134.7813 107.5156,133.6875 107.5156,131.9844 L107.5156,130.8906 C107.5156,129.1094 108.7656,127.7969 110.5,127.7969 C111.0781,127.7969 111.6875,127.9531 112.1563,128.2031 C112.6406,128.4844 112.8125,128.7031 112.9063,129.1094 C112.9688,129.5156 113,129.6406 113.1406,129.7656 C113.2813,129.9063 113.5156,130.0156 113.7344,130.0156 C114,130.0156 114.2656,129.875 114.4375,129.6563 C114.5469,129.5 114.5781,129.3125 114.5781,128.8906 L114.5781,127.4688 C114.5781,127.0313 114.5625,126.9063 114.4688,126.75 C114.3125,126.4844 114.0313,126.3438 113.7344,126.3438 C113.4375,126.3438 113.2344,126.4375 113.0156,126.75 L112.8438,126.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="96" x="124.5" y="135.8467">RecyclerView</text><line style="stroke:#181818;stroke-width:0.5;" x1="96.5" x2="222.5" y1="147" y2="147"/><line style="stroke:#181818;stroke-width:0.5;" x1="96.5" x2="222.5" y1="155" y2="155"/></g><!--class ScrollingView--><g id="elem_ScrollingView"><rect codeLine="2" fill="#F1F1F1" height="48" id="ScrollingView" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="128" x="172.5" y="7"/><ellipse cx="187.5" cy="23" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M188.4531,19.7813 L190.1719,19.7813 C190.5625,19.7813 190.75,19.75 190.875,19.6719 C191.1406,19.5156 191.2813,19.2344 191.2813,18.9375 C191.2813,18.6719 191.1719,18.4063 190.9375,18.2344 C190.7656,18.125 190.625,18.0938 190.1719,18.0938 L185.0313,18.0938 C184.5938,18.0938 184.4688,18.1094 184.3125,18.2031 C184.0625,18.3594 183.9063,18.6563 183.9063,18.9375 C183.9063,19.2188 184.0469,19.4688 184.2656,19.6406 C184.4219,19.75 184.6094,19.7813 185.0313,19.7813 L186.75,19.7813 L186.75,26.2969 L185.0313,26.2969 C184.5938,26.2969 184.4688,26.3125 184.3125,26.4219 C184.0625,26.5781 183.9063,26.8594 183.9063,27.1563 C183.9063,27.4063 184.0469,27.6719 184.2656,27.8281 C184.4219,27.9531 184.625,28 185.0313,28 L190.1719,28 C190.9219,28 191.2813,27.7188 191.2813,27.1563 C191.2813,26.875 191.1719,26.625 190.9375,26.4531 C190.7656,26.3281 190.625,26.2969 190.1719,26.2969 L188.4531,26.2969 L188.4531,19.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="96" x="201.5" y="27.8467">ScrollingView</text><line style="stroke:#181818;stroke-width:0.5;" x1="173.5" x2="299.5" y1="39" y2="39"/><line style="stroke:#181818;stroke-width:0.5;" x1="173.5" x2="299.5" y1="47" y2="47"/></g><!--class Recycler--><g id="elem_Recycler"><rect codeLine="4" fill="#F1F1F1" height="113.1875" id="Recycler" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="305" x="7" y="223"/><ellipse cx="124.25" cy="239" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M126.5938,234.6719 C125.6563,234.2344 125.0625,234.0938 124.1875,234.0938 C121.5625,234.0938 119.5625,236.1719 119.5625,238.8906 L119.5625,240.0156 C119.5625,242.5938 121.6719,244.4844 124.5625,244.4844 C125.7813,244.4844 126.9375,244.1875 127.6875,243.6406 C128.2656,243.2344 128.5938,242.7813 128.5938,242.3906 C128.5938,241.9375 128.2031,241.5469 127.7344,241.5469 C127.5156,241.5469 127.3125,241.625 127.125,241.8125 C126.6719,242.2969 126.6719,242.2969 126.4844,242.3906 C126.0625,242.6563 125.375,242.7813 124.6094,242.7813 C122.5625,242.7813 121.2656,241.6875 121.2656,239.9844 L121.2656,238.8906 C121.2656,237.1094 122.5156,235.7969 124.25,235.7969 C124.8281,235.7969 125.4375,235.9531 125.9063,236.2031 C126.3906,236.4844 126.5625,236.7031 126.6563,237.1094 C126.7188,237.5156 126.75,237.6406 126.8906,237.7656 C127.0313,237.9063 127.2656,238.0156 127.4844,238.0156 C127.75,238.0156 128.0156,237.875 128.1875,237.6563 C128.2969,237.5 128.3281,237.3125 128.3281,236.8906 L128.3281,235.4688 C128.3281,235.0313 128.3125,234.9063 128.2188,234.75 C128.0625,234.4844 127.7813,234.3438 127.4844,234.3438 C127.1875,234.3438 126.9844,234.4375 126.7656,234.75 L126.5938,234.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="62" x="144.75" y="243.8467">Recycler</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="311" y1="255" y2="255"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="293" x="13" y="271.9951">ArrayList&lt;ViewHolder&gt; mAttachedScrap</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="289" x="13" y="288.292">ArrayList&lt;ViewHolder&gt; mChangedScrap</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="279" x="13" y="304.5889">ArrayList&lt;ViewHolder&gt; mCachedViews</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="241" x="13" y="320.8857">RecycledViewPool mRecyclerPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="311" y1="328.1875" y2="328.1875"/></g><!--class RecycledViewPool--><g id="elem_RecycledViewPool"><rect fill="#F1F1F1" height="48" id="RecycledViewPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="162" x="78.5" y="396"/><ellipse cx="93.5" cy="412" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M95.8438,407.6719 C94.9063,407.2344 94.3125,407.0938 93.4375,407.0938 C90.8125,407.0938 88.8125,409.1719 88.8125,411.8906 L88.8125,413.0156 C88.8125,415.5938 90.9219,417.4844 93.8125,417.4844 C95.0313,417.4844 96.1875,417.1875 96.9375,416.6406 C97.5156,416.2344 97.8438,415.7813 97.8438,415.3906 C97.8438,414.9375 97.4531,414.5469 96.9844,414.5469 C96.7656,414.5469 96.5625,414.625 96.375,414.8125 C95.9219,415.2969 95.9219,415.2969 95.7344,415.3906 C95.3125,415.6563 94.625,415.7813 93.8594,415.7813 C91.8125,415.7813 90.5156,414.6875 90.5156,412.9844 L90.5156,411.8906 C90.5156,410.1094 91.7656,408.7969 93.5,408.7969 C94.0781,408.7969 94.6875,408.9531 95.1563,409.2031 C95.6406,409.4844 95.8125,409.7031 95.9063,410.1094 C95.9688,410.5156 96,410.6406 96.1406,410.7656 C96.2813,410.9063 96.5156,411.0156 96.7344,411.0156 C97,411.0156 97.2656,410.875 97.4375,410.6563 C97.5469,410.5 97.5781,410.3125 97.5781,409.8906 L97.5781,408.4688 C97.5781,408.0313 97.5625,407.9063 97.4688,407.75 C97.3125,407.4844 97.0313,407.3438 96.7344,407.3438 C96.4375,407.3438 96.2344,407.4375 96.0156,407.75 L95.8438,407.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="130" x="107.5" y="416.8467">RecycledViewPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="79.5" x2="239.5" y1="428" y2="428"/><line style="stroke:#181818;stroke-width:0.5;" x1="79.5" x2="239.5" y1="436" y2="436"/></g><!--reverse link ViewGroup to RecyclerView--><g id="link_ViewGroup_RecyclerView"><path codeLine="1" d="M109.7869,69.5632 C122.614,87.2212 129.674,96.941 142.559,114.678 " fill="none" id="ViewGroup-backto-RecyclerView" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="99.2079,55,104.9325,73.0895,114.6412,66.0368,99.2079,55" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link ScrollingView to RecyclerView--><g id="link_ScrollingView_RecyclerView"><path codeLine="3" d="M209.2131,69.5632 C196.3861,87.2212 189.326,96.941 176.441,114.678 " fill="none" id="ScrollingView-backto-RecyclerView" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:7.0,7.0;"/><polygon fill="none" points="219.792,55,204.3587,66.0369,214.0675,73.0895,219.792,55" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link RecyclerView to Recycler--><g id="link_RecyclerView_Recycler"><path codeLine="10" d="M159.5,175.182 C159.5,191.507 159.5,202.084 159.5,222.937 " fill="none" id="RecyclerView-backto-Recycler" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="159.5,163.182,155.5,169.182,159.5,175.182,163.5,169.182,159.5,163.182" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link Recycler to RecycledViewPool--><g id="link_Recycler_RecycledViewPool"><path codeLine="11" d="M159.5,348.035 C159.5,368.9568 159.5,379.6181 159.5,395.9619 " fill="none" id="Recycler-backto-RecycledViewPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="159.5,336.035,155.5,342.035,159.5,348.035,163.5,342.035,159.5,336.035" style="stroke:#181818;stroke-width:1.0;"/></g><!--SRC=[2yjCBNSloYyjKB2fqTLL24fDhapEIIqA0mfpPUQLf1Qb9IQdAWGd5-Ndv6JcfOF5KNX0VNfwgFgISnABY-522jLS2a3WM5IKMEcJMLnY0rBZaP-Jabfafv3hM5AIc9oHcW8qCx40dqBdZCIyT6BKWOq32HM3bK6T0HO9oC_FKSY5EGp4uwhbGdQwWXPI6C1ba4NXvW00]--></g></svg>

<h2 id="删除View缓存使用图解"><a href="#删除View缓存使用图解" class="headerlink" title="删除View缓存使用图解"></a>删除View缓存使用图解</h2><p><img src="/images/RecyclerView/remove_item.drawio.svg" alt="RecyclerView移除元素"></p>
<p>在垂直布局的RecyclerView中展示了Item0~Item4这5个TextView，我们现在把Item2删掉。数据更新后，我们调用<code>Adapter#notifyItemRemoved(2)</code>来提交更新。</p>
<p><img src="/images/RecyclerView/remove_item_cache_use_sequence.drawio.svg" alt="RecyclerView删除Item"></p>
<p><strong>dispatchLayoutStep1阶段：</strong></p>
<ol>
<li>调用detachViewFromParent把Item0~Item4这五个View从RecyclerView中detache掉，然后放入把ViewHolder放入mAttachedScrap进行缓存。ViewHodler都会被标记为FLAG_TMP_DETACHED，并且Item2会被标记为FLAG_REMOVED；</li>
<li>然后layout进行填充，把Item0~Item4从mAttachedScrap中取出，然后调用attachViewToParent重新加入到RecyclerView中。</li>
<li>调用onCreateViewHolder创建一个新ViewHolder（Item5），执行onBindViewHolder，并addView到RecyclerView中。</li>
</ol>
<p><strong>dispatchLayoutStep2阶段：</strong></p>
<ol>
<li>调用detachViewFromParent把Item0~Item5这六个View从RecyclerView中detache掉，然后把ViewHolder放入mAttachedScrap进行缓存。ViewHolder都会被标记为FLAG_TMP_DETACHED，并且Item2会被标记为FLAG_REMOVED；</li>
<li>除了Item2的ViewHolder之外，把其他ViewHolder从mAttachedScrap缓存中取出，然后调用attachViewToParent重新加入到RecyclerView中。</li>
</ol>
<p><strong>dispatchLayoutStep3阶段：</strong></p>
<ol>
<li>从mAttachedScrap取出Item2，然后把Item2 View添加到mHiddenViews中；</li>
<li>在Item2 ItemAnimator的onAnimationFinished事件中把Item2从mAttachedScrap中移除，添加到RecycledViewPool中。</li>
</ol>
<h2 id="修改View缓存使用图解"><a href="#修改View缓存使用图解" class="headerlink" title="修改View缓存使用图解"></a>修改View缓存使用图解</h2><p><img src="/images/RecyclerView/change_item_text.drawio.svg" alt="RecyclerView修改Item"></p>
<p>RecyclerView中包含Item0~Item4共五个TextView，我们把Item2的文案更新为”New 2”。通过调用<code>Adapter#notifyItemChanged(2)</code>来通知RecyclerView进行更新。</p>
<p><img src="/images/RecyclerView/change_item_sequence.drawio.svg" alt="RecyclerView修改"></p>
<h2 id="插入View缓存使用图解"><a href="#插入View缓存使用图解" class="headerlink" title="插入View缓存使用图解"></a>插入View缓存使用图解</h2><p><img src="/images/RecyclerView/insert_item.drawio.svg" alt="RecyclerView插入Item"></p>
<p><img src="/images/RecyclerView/insert_item_sequence.drawio.svg" alt="RecyclerView插入Item时序"></p>
<h2 id="预加载缓存-mCachedViews"><a href="#预加载缓存-mCachedViews" class="headerlink" title="预加载缓存 mCachedViews"></a>预加载缓存 mCachedViews</h2><p>预加载的view会放在这里，这个数组最大默认是2。首次绘制出来，如果没有滑动屏幕，mCachedViews为空，当滑动UI后会将预加载的一个，以及划出的加入缓存中。</p>
<p><img src="/images/RecyclerView_mCachedViews.drawio.svg" alt="mCachedViews存储元素"></p>
<p>如果是向下滑动，则屏幕下面的元素会缓存两个，比如上图右边向下把H滑出屏幕，而C会露出，则mCachedViews中保存的是[B, H, I]。</p>
<h3 id="滑动时预加载流程"><a href="#滑动时预加载流程" class="headerlink" title="滑动时预加载流程"></a>滑动时预加载流程</h3><p><code>androidx.recyclerview.widget.RecyclerView#onTouchEvent</code>接收到<code>MotionEvent.ACTION_MOVE</code>事件时，如果判断滑动超过一定的距离时，就任务用户自滑动操作。然后就会调用<code>GapWorker#postFromTraversal</code></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//androidx/recyclerview/widget/GapWorker.java</span></span><br><span class="line">    <span class="keyword">void</span> <span class="title function_">postFromTraversal</span><span class="params">(RecyclerView recyclerView, <span class="type">int</span> prefetchDx, <span class="type">int</span> prefetchDy)</span> &#123;</span><br><span class="line">        <span class="keyword">if</span> (recyclerView.isAttachedToWindow()) &#123;</span><br><span class="line">            <span class="keyword">if</span> (RecyclerView.DEBUG &amp;&amp; !mRecyclerViews.contains(recyclerView)) &#123;</span><br><span class="line">                <span class="keyword">throw</span> <span class="keyword">new</span> <span class="title class_">IllegalStateException</span>(<span class="string">&quot;attempting to post unregistered view!&quot;</span>);</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span> (mPostTimeNs == <span class="number">0</span>) &#123;</span><br><span class="line">                mPostTimeNs = recyclerView.getNanoTime();</span><br><span class="line">                recyclerView.post(<span class="built_in">this</span>); <span class="comment">//将自己转到主线程去执行</span></span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">//设置用户滑动的距离</span></span><br><span class="line">        recyclerView.mPrefetchRegistry.setPrefetchVector(prefetchDx, prefetchDy);</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="777px" preserveAspectRatio="none" style="width:837px;height:777px;background:#FFFFFF;" version="1.1" viewBox="0 0 837 777" width="837px" zoomAndPan="magnify"><defs/><g><rect fill="#FFFFFF" height="629.125" style="stroke:#181818;stroke-width:1.0;" width="10" x="48" y="104.5625"/><rect fill="#FFFFFF" height="415.4609" style="stroke:#181818;stroke-width:1.0;" width="10" x="53" y="146.6953"/><rect fill="#FFFFFF" height="127.3984" style="stroke:#181818;stroke-width:1.0;" width="10" x="53" y="606.2891"/><rect fill="#FFFFFF" height="85.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="58" y="648.4219"/><rect fill="#FFFFFF" height="43.1328" style="stroke:#181818;stroke-width:1.0;" width="10" x="63" y="690.5547"/><rect fill="#FFFFFF" height="116.3984" style="stroke:#181818;stroke-width:1.0;" width="10" x="373" y="180.8281"/><rect fill="#FFFFFF" height="122.3984" style="stroke:#181818;stroke-width:1.0;" width="10" x="373" y="368.4922"/><rect fill="#FFFFFF" height="131.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="610" y="267.2266"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="53" x2="53" y1="36.2969" y2="742.6875"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="377.5" x2="377.5" y1="36.2969" y2="742.6875"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="614.5" x2="614.5" y1="36.2969" y2="742.6875"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="793" x2="793" y1="36.2969" y2="742.6875"/><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="96" x="5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="82" x="12" y="24.9951">GapWorker</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="96" x="5" y="741.6875"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="82" x="12" y="761.6826">GapWorker</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="217" x="269.5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="203" x="276.5" y="24.9951">LayoutPrefetchRegistryImpl</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="217" x="269.5" y="741.6875"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="203" x="276.5" y="761.6826">LayoutPrefetchRegistryImpl</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="167" x="531.5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="153" x="538.5" y="24.9951">LinearLayoutManager</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="167" x="531.5" y="741.6875"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="153" x="538.5" y="761.6826">LinearLayoutManager</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="76" x="755" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="62" x="762" y="24.9951">Recycler</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="76" x="755" y="741.6875"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="62" x="762" y="761.6826">Recycler</text><rect fill="#FFFFFF" height="629.125" style="stroke:#181818;stroke-width:1.0;" width="10" x="48" y="104.5625"/><rect fill="#FFFFFF" height="415.4609" style="stroke:#181818;stroke-width:1.0;" width="10" x="53" y="146.6953"/><rect fill="#FFFFFF" height="127.3984" style="stroke:#181818;stroke-width:1.0;" width="10" x="53" y="606.2891"/><rect fill="#FFFFFF" height="85.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="58" y="648.4219"/><rect fill="#FFFFFF" height="43.1328" style="stroke:#181818;stroke-width:1.0;" width="10" x="63" y="690.5547"/><rect fill="#FFFFFF" height="116.3984" style="stroke:#181818;stroke-width:1.0;" width="10" x="373" y="180.8281"/><rect fill="#FFFFFF" height="122.3984" style="stroke:#181818;stroke-width:1.0;" width="10" x="373" y="368.4922"/><rect fill="#FFFFFF" height="131.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="610" y="267.2266"/><ellipse cx="7.5" cy="66.6797" fill="none" rx="4" ry="4" style="stroke:#181818;stroke-width:1.5;"/><polygon fill="#181818" points="41,63.4297,51,67.4297,41,71.4297,45,67.4297" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="12" x2="47" y1="67.4297" y2="67.4297"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="21" x="15" y="62.3638">run</text><line style="stroke:#181818;stroke-width:1.0;" x1="53" x2="100" y1="91.5625" y2="91.5625"/><line style="stroke:#181818;stroke-width:1.0;" x1="100" x2="100" y1="91.5625" y2="104.5625"/><line style="stroke:#181818;stroke-width:1.0;" x1="59" x2="100" y1="104.5625" y2="104.5625"/><polygon fill="#181818" points="69,100.5625,59,104.5625,69,108.5625,65,104.5625" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="54" x="65" y="86.4966">prefetch</text><line style="stroke:#181818;stroke-width:1.0;" x1="58" x2="105" y1="133.6953" y2="133.6953"/><line style="stroke:#181818;stroke-width:1.0;" x1="105" x2="105" y1="133.6953" y2="146.6953"/><line style="stroke:#181818;stroke-width:1.0;" x1="64" x2="105" y1="146.6953" y2="146.6953"/><polygon fill="#181818" points="74,142.6953,64,146.6953,74,150.6953,70,146.6953" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="82" x="70" y="128.6294">buildTaskList</text><polygon fill="#181818" points="361,176.8281,371,180.8281,361,184.8281,365,180.8281" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="63" x2="367" y1="180.8281" y2="180.8281"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="216" x="70" y="175.7622">collectPrefetchPositionsFromView</text><line style="stroke:#181818;stroke-width:1.0;" x1="383" x2="425" y1="209.9609" y2="209.9609"/><line style="stroke:#181818;stroke-width:1.0;" x1="425" x2="425" y1="209.9609" y2="222.9609"/><line style="stroke:#181818;stroke-width:1.0;" x1="384" x2="425" y1="222.9609" y2="222.9609"/><polygon fill="#181818" points="394,218.9609,384,222.9609,394,226.9609,390,222.9609" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="81" x="390" y="204.895">mCount &#28165;&#38646;</text><polygon fill="#181818" points="598,263.2266,608,267.2266,598,271.2266,602,267.2266" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="383" x2="604" y1="267.2266" y2="267.2266"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="208" x="390" y="247.0278">collectAdjacentPrefetchPositions</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="91" x="390" y="262.1606">&#39044;&#21152;&#36733;&#20020;&#36817;&#20803;&#32032;</text><line style="stroke:#181818;stroke-width:1.0;" x1="620" x2="662" y1="326.3594" y2="326.3594"/><line style="stroke:#181818;stroke-width:1.0;" x1="662" x2="662" y1="326.3594" y2="339.3594"/><line style="stroke:#181818;stroke-width:1.0;" x1="621" x2="662" y1="339.3594" y2="339.3594"/><polygon fill="#181818" points="631,335.3594,621,339.3594,631,343.3594,627,339.3594" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="154" x="627" y="321.2935">&#33719;&#21462;&#19979;&#19968;&#20010;&#20803;&#32032;&#30340;position</text><polygon fill="#181818" points="394,364.4922,384,368.4922,394,372.4922,390,368.4922" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="388" x2="609" y1="368.4922" y2="368.4922"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="74" x="400" y="363.4263">addPosition</text><line style="stroke:#181818;stroke-width:1.0;" x1="383" x2="425" y1="442.7578" y2="442.7578"/><line style="stroke:#181818;stroke-width:1.0;" x1="425" x2="425" y1="442.7578" y2="455.7578"/><line style="stroke:#181818;stroke-width:1.0;" x1="384" x2="425" y1="455.7578" y2="455.7578"/><polygon fill="#181818" points="394,451.7578,384,455.7578,394,459.7578,390,455.7578" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="141" x="390" y="422.5591">&#39044;&#21152;&#36733;&#30340;position&#20445;&#23384;&#21040;</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="141" x="390" y="437.6919">mPrefetchArray&#25968;&#32452;&#20013;</text><line style="stroke:#181818;stroke-width:1.0;" x1="383" x2="425" y1="489.8906" y2="489.8906"/><line style="stroke:#181818;stroke-width:1.0;" x1="425" x2="425" y1="489.8906" y2="502.8906"/><line style="stroke:#181818;stroke-width:1.0;" x1="378" x2="425" y1="502.8906" y2="502.8906"/><polygon fill="#181818" points="388,498.8906,378,502.8906,388,506.8906,384,502.8906" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="81" x="390" y="484.8247">mCount &#21152;&#19968;</text><polygon fill="#181818" points="74,523.0234,64,527.0234,74,531.0234,70,527.0234" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" x1="68" x2="377" y1="527.0234" y2="527.0234"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="39" x="80" y="521.9575">return</text><line style="stroke:#181818;stroke-width:1.0;" x1="63" x2="105" y1="561.1563" y2="561.1563"/><line style="stroke:#181818;stroke-width:1.0;" x1="105" x2="105" y1="561.1563" y2="574.1563"/><line style="stroke:#181818;stroke-width:1.0;" x1="58" x2="105" y1="574.1563" y2="574.1563"/><polygon fill="#181818" points="68,570.1563,58,574.1563,68,578.1563,64,574.1563" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="296" x="70" y="556.0903">&#26681;&#25454;mCount&#25968;&#37327;&#28155;&#21152;&#39044;&#21152;&#36733;&#20219;&#21153;&#21040;mTasks&#21015;&#34920;&#20013;</text><line style="stroke:#181818;stroke-width:1.0;" x1="58" x2="105" y1="593.2891" y2="593.2891"/><line style="stroke:#181818;stroke-width:1.0;" x1="105" x2="105" y1="593.2891" y2="606.2891"/><line style="stroke:#181818;stroke-width:1.0;" x1="64" x2="105" y1="606.2891" y2="606.2891"/><polygon fill="#181818" points="74,602.2891,64,606.2891,74,610.2891,70,606.2891" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="153" x="70" y="588.2231">flushTasksWithDeadline</text><line style="stroke:#181818;stroke-width:1.0;" x1="63" x2="110" y1="635.4219" y2="635.4219"/><line style="stroke:#181818;stroke-width:1.0;" x1="110" x2="110" y1="635.4219" y2="648.4219"/><line style="stroke:#181818;stroke-width:1.0;" x1="69" x2="110" y1="648.4219" y2="648.4219"/><polygon fill="#181818" points="79,644.4219,69,648.4219,79,652.4219,75,648.4219" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="146" x="75" y="630.356">flushTaskWithDeadline</text><line style="stroke:#181818;stroke-width:1.0;" x1="68" x2="115" y1="677.5547" y2="677.5547"/><line style="stroke:#181818;stroke-width:1.0;" x1="115" x2="115" y1="677.5547" y2="690.5547"/><line style="stroke:#181818;stroke-width:1.0;" x1="74" x2="115" y1="690.5547" y2="690.5547"/><polygon fill="#181818" points="84,686.5547,74,690.5547,84,694.5547,80,690.5547" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="189" x="80" y="672.4888">prefetchPositionWithDeadline</text><polygon fill="#181818" points="781,720.6875,791,724.6875,781,728.6875,785,724.6875" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="73" x2="787" y1="724.6875" y2="724.6875"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="255" x="80" y="719.6216">tryGetViewHolderForPositionByDeadline</text><!--SRC=[dPDTIy9G6CVl_HIx5x_0BW8hjC109F8YRqxRKPTdE-FihDXTa98K9LtqGX5eLn4ONaWkHFmosvpVehEfCwqjyVBmFF_VytzUpY5ER71feEOngK32yHpHbTZylH2CntbE9R08gL2EoZdI9IJk0wsIaJIwc9W11jPfTWh9mHBB8CQkh29VAM24e134irYJg8GLBKMmV231qrY4FfhES_8MrXNAEMPj_Fpv7qXI822Jd3sWW9BVMI8HE4oAnq20oc-d1MNyMhKlc-vWO9bTTtXhryv7tMRiBs988PvpRtfsuzuohoppp3BV9uZHKrMTLWcbHKtNSmz4CHimrXzbqE8FJzRmnMu_slLEGP5diYGXm73kEgD-rJBRwrVqh4_Nn-goeKIYbWyQKfs4tZJFESqlv_fZWcTUnnSDfzTdPUPxxBDdYtKcUpUjsVK7j_NczID2853f150u1qRzYoBIjRBFo4kql0s1YDWULrAiAb2NxZ5SbuE28I1_0cnoQKYz_xM3aGX92fEPVjEOgRy1]--></g></svg>

<h2 id="mAttachedScrap"><a href="#mAttachedScrap" class="headerlink" title="mAttachedScrap"></a>mAttachedScrap</h2><p>先看下源码执行流程：</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="366px" preserveAspectRatio="none" style="width:979px;height:366px;background:#FFFFFF;" version="1.1" viewBox="0 0 979 366" width="979px" zoomAndPan="magnify"><defs/><g><rect fill="#FFFFFF" height="59.1328" style="stroke:#181818;stroke-width:1.0;" width="10" x="173" y="67.4297"/><rect fill="#FFFFFF" height="225.7969" style="stroke:#181818;stroke-width:1.0;" width="10" x="380" y="96.5625"/><rect fill="#FFFFFF" height="50.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="587" y="155.6953"/><rect fill="#FFFFFF" height="80.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="767" y="242.0938"/><rect fill="#FFFFFF" height="34.1328" style="stroke:#181818;stroke-width:1.0;" width="10" x="772" y="279.2266"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="177.5" x2="177.5" y1="36.2969" y2="331.3594"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="385" x2="385" y1="36.2969" y2="331.3594"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="591.5" x2="591.5" y1="36.2969" y2="331.3594"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="772" x2="772" y1="36.2969" y2="331.3594"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="949" x2="949" y1="36.2969" y2="331.3594"/><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="73" x="141.5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="59" x="148.5" y="24.9951">Adapter</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="73" x="141.5" y="330.3594"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="59" x="148.5" y="350.3545">Adapter</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="210" x="280" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="196" x="287" y="24.9951">RecyclerViewDataObserver</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="210" x="280" y="330.3594"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="196" x="287" y="350.3545">RecyclerViewDataObserver</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="121" x="531.5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="107" x="538.5" y="24.9951">AdapterHelper</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="121" x="531.5" y="330.3594"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="107" x="538.5" y="350.3545">AdapterHelper</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="110" x="717" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="96" x="724" y="24.9951">RecyclerView</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="110" x="717" y="330.3594"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="96" x="724" y="350.3545">RecyclerView</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="48" x="925" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="34" x="932" y="24.9951">View</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="48" x="925" y="330.3594"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="34" x="932" y="350.3545">View</text><rect fill="#FFFFFF" height="59.1328" style="stroke:#181818;stroke-width:1.0;" width="10" x="173" y="67.4297"/><rect fill="#FFFFFF" height="225.7969" style="stroke:#181818;stroke-width:1.0;" width="10" x="380" y="96.5625"/><rect fill="#FFFFFF" height="50.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="587" y="155.6953"/><rect fill="#FFFFFF" height="80.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="767" y="242.0938"/><rect fill="#FFFFFF" height="34.1328" style="stroke:#181818;stroke-width:1.0;" width="10" x="772" y="279.2266"/><ellipse cx="7.5" cy="66.6797" fill="none" rx="4" ry="4" style="stroke:#181818;stroke-width:1.5;"/><polygon fill="#181818" points="161,63.4297,171,67.4297,161,71.4297,165,67.4297" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="12" x2="167" y1="67.4297" y2="67.4297"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="146" x="15" y="62.3638">notifyItemRemoved(2)</text><polygon fill="#181818" points="368,92.5625,378,96.5625,368,100.5625,372,96.5625" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="183" x2="374" y1="96.5625" y2="96.5625"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="178" x="190" y="91.4966">onItemRangeRemoved(2,1)</text><polygon fill="#181818" points="575,151.6953,585,155.6953,575,159.6953,579,155.6953" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="390" x2="581" y1="155.6953" y2="155.6953"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="178" x="397" y="150.6294">onItemRangeRemoved(2,1)</text><line style="stroke:#181818;stroke-width:1.0;" x1="597" x2="639" y1="204.9609" y2="204.9609"/><line style="stroke:#181818;stroke-width:1.0;" x1="639" x2="639" y1="204.9609" y2="217.9609"/><line style="stroke:#181818;stroke-width:1.0;" x1="592" x2="639" y1="217.9609" y2="217.9609"/><polygon fill="#181818" points="602,213.9609,592,217.9609,602,221.9609,598,217.9609" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="155" x="604" y="184.7622">&#28155;&#21152;&#19968;&#20010;UpdateOp&#25351;&#20196;&#21040;</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="156" x="604" y="199.895">mPendingUpdates&#21015;&#34920;&#20013;</text><polygon fill="#181818" points="755,238.0938,765,242.0938,755,246.0938,759,242.0938" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="390" x2="761" y1="242.0938" y2="242.0938"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="161" x="397" y="237.0278">triggerUpdateProcessor()</text><line style="stroke:#181818;stroke-width:1.0;" x1="777" x2="824" y1="266.2266" y2="266.2266"/><line style="stroke:#181818;stroke-width:1.0;" x1="824" x2="824" y1="266.2266" y2="279.2266"/><line style="stroke:#181818;stroke-width:1.0;" x1="783" x2="824" y1="279.2266" y2="279.2266"/><polygon fill="#181818" points="793,275.2266,783,279.2266,793,283.2266,789,279.2266" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="103" x="789" y="261.1606">requestLayout()</text><polygon fill="#181818" points="937,309.3594,947,313.3594,937,317.3594,941,313.3594" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="777" x2="943" y1="313.3594" y2="313.3594"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="143" x="784" y="308.2935">super.requestLayout()</text><!--SRC=[YyxNjLDmJ4aiA4ajKj3MjbB8oo_9JAlqB4dD3KhDpIzBJT4mqkI2AG2g3KfDhapEIIqAoqmjTqaiIVHFAaujAWDhrjMrKiZF0sjDp4jFXUlNCTJamgaDORr7Qau1r16uJ45LYQ4Lv81dstS_xLhmP4V3anshGWjI4ajI_GkUzRG_sRtaQSU6cBpSWDIybCoyT8XKyTEEwIyMhdYoOorU1oBBWTrNKfIPdfvQ134ae2W_ERMuEBz80zMRM7KMfHQMfXQN-2HMvfUMOD40eO7-A2u5-aWFJJa0]--></g></svg>

<p>从上面时序图可以看出，最终调用到了父类<code>View#requestLayout()</code>，然后调用<code>mParent.requestLayout();</code>，沿着view层级一直调用到<code>android.view.ViewRootImpl#requestLayout()</code>。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//android-31\android\view\ViewRootImpl.java</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">requestLayout</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">if</span> (!mHandlingLayoutInLayoutRequest) &#123;</span><br><span class="line">            checkThread();</span><br><span class="line">            mLayoutRequested = <span class="literal">true</span>;</span><br><span class="line">            scheduleTraversals();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">void</span> <span class="title function_">scheduleTraversals</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">if</span> (!mTraversalScheduled) &#123;</span><br><span class="line">            mTraversalScheduled = <span class="literal">true</span>;</span><br><span class="line">            <span class="comment">//添加同步屏障，保障vsync信号会优先执行</span></span><br><span class="line">            mTraversalBarrier = mHandler.getLooper().getQueue().postSyncBarrier();</span><br><span class="line">            <span class="comment">//等待下一个vsync信号来执行TraversalRunnable</span></span><br><span class="line">            mChoreographer.postCallback(</span><br><span class="line">                    Choreographer.CALLBACK_TRAVERSAL, mTraversalRunnable, <span class="literal">null</span>);</span><br><span class="line">            notifyRendererOfFramePending();</span><br><span class="line">            pokeDrawLockIfNeeded();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">final</span> <span class="keyword">class</span> <span class="title class_">TraversalRunnable</span> <span class="keyword">implements</span> <span class="title class_">Runnable</span> &#123;</span><br><span class="line">        <span class="meta">@Override</span></span><br><span class="line">        <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">run</span><span class="params">()</span> &#123;</span><br><span class="line">            doTraversal();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">final</span> <span class="type">TraversalRunnable</span> <span class="variable">mTraversalRunnable</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">TraversalRunnable</span>();</span><br><span class="line">    <span class="keyword">void</span> <span class="title function_">doTraversal</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">if</span> (mTraversalScheduled) &#123;</span><br><span class="line">            mTraversalScheduled = <span class="literal">false</span>;</span><br><span class="line">            <span class="comment">//移除同步屏障</span></span><br><span class="line">            mHandler.getLooper().getQueue().removeSyncBarrier(mTraversalBarrier);</span><br><span class="line"></span><br><span class="line">            <span class="keyword">if</span> (mProfile) &#123;</span><br><span class="line">                Debug.startMethodTracing(<span class="string">&quot;ViewAncestor&quot;</span>);</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            performTraversals();</span><br><span class="line"></span><br><span class="line">            <span class="keyword">if</span> (mProfile) &#123;</span><br><span class="line">                Debug.stopMethodTracing();</span><br><span class="line">                mProfile = <span class="literal">false</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<p>从上面可以看出，requestLayout不会立马执行，而是等待下一个vsync信号到来再执行，最终执行<code>android.view.ViewRootImpl#performTraversals</code>，这个函数很长有800多行，这里就不贴代码了，这里面就会View的绘制的measure、layout、draw三大流程。分别对应：<code>ViewRootImpl#measureHierarchy</code>、<code>ViewRootImpl#performLayout</code>、<code>ViewRootImpl#performDraw</code>。</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="859px" preserveAspectRatio="none" style="width:915px;height:859px;background:#FFFFFF;" version="1.1" viewBox="0 0 915 859" width="915px" zoomAndPan="magnify"><defs/><g><rect fill="#FFFFFF" height="747.3203" style="stroke:#181818;stroke-width:1.0;" width="10" x="87" y="67.4297"/><rect fill="#FFFFFF" height="710.1875" style="stroke:#181818;stroke-width:1.0;" width="10" x="92" y="104.5625"/><rect fill="#FFFFFF" height="668.0547" style="stroke:#181818;stroke-width:1.0;" width="10" x="97" y="146.6953"/><rect fill="#FFFFFF" height="633.9219" style="stroke:#181818;stroke-width:1.0;" width="10" x="251" y="180.8281"/><rect fill="#FFFFFF" height="363.7266" style="stroke:#181818;stroke-width:1.0;" width="10" x="256" y="451.0234"/><rect fill="#FFFFFF" height="297.4609" style="stroke:#181818;stroke-width:1.0;" width="10" x="261" y="517.2891"/><rect fill="#FFFFFF" height="211.9297" style="stroke:#181818;stroke-width:1.0;" width="10" x="481" y="209.9609"/><rect fill="#FFFFFF" height="161.7969" style="stroke:#181818;stroke-width:1.0;" width="10" x="481" y="652.9531"/><rect fill="#FFFFFF" height="50.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="649" y="349.625"/><rect fill="#FFFFFF" height="65.3984" style="stroke:#181818;stroke-width:1.0;" width="10" x="649" y="551.4219"/><rect fill="#FFFFFF" height="50.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="649" y="682.0859"/><rect fill="none" height="189.9297" style="stroke:#000000;stroke-width:1.5;" width="797" x="27" y="224.9609"/><rect fill="none" height="335.7266" style="stroke:#000000;stroke-width:1.5;" width="882" x="27" y="471.0234"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="92" x2="92" y1="36.2969" y2="823.75"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="255.5" x2="255.5" y1="36.2969" y2="823.75"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="486" x2="486" y1="36.2969" y2="823.75"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="654" x2="654" y1="36.2969" y2="823.75"/><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="110" x="37" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="96" x="44" y="24.9951">RecyclerView</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="110" x="37" y="822.75"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="96" x="44" y="842.7451">RecyclerView</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="159" x="176.5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="145" x="183.5" y="24.9951">LinerLayoutManager</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="159" x="176.5" y="822.75"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="145" x="183.5" y="842.7451">LinerLayoutManager</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="224" x="374" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="210" x="381" y="24.9951">RecyclerView.LayoutManager</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="224" x="374" y="822.75"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="210" x="381" y="842.7451">RecyclerView.LayoutManager</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="76" x="616" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="62" x="623" y="24.9951">Recycler</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="76" x="616" y="822.75"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="62" x="623" y="842.7451">Recycler</text><rect fill="#FFFFFF" height="747.3203" style="stroke:#181818;stroke-width:1.0;" width="10" x="87" y="67.4297"/><rect fill="#FFFFFF" height="710.1875" style="stroke:#181818;stroke-width:1.0;" width="10" x="92" y="104.5625"/><rect fill="#FFFFFF" height="668.0547" style="stroke:#181818;stroke-width:1.0;" width="10" x="97" y="146.6953"/><rect fill="#FFFFFF" height="633.9219" style="stroke:#181818;stroke-width:1.0;" width="10" x="251" y="180.8281"/><rect fill="#FFFFFF" height="363.7266" style="stroke:#181818;stroke-width:1.0;" width="10" x="256" y="451.0234"/><rect fill="#FFFFFF" height="297.4609" style="stroke:#181818;stroke-width:1.0;" width="10" x="261" y="517.2891"/><rect fill="#FFFFFF" height="211.9297" style="stroke:#181818;stroke-width:1.0;" width="10" x="481" y="209.9609"/><rect fill="#FFFFFF" height="161.7969" style="stroke:#181818;stroke-width:1.0;" width="10" x="481" y="652.9531"/><rect fill="#FFFFFF" height="50.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="649" y="349.625"/><rect fill="#FFFFFF" height="65.3984" style="stroke:#181818;stroke-width:1.0;" width="10" x="649" y="551.4219"/><rect fill="#FFFFFF" height="50.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="649" y="682.0859"/><ellipse cx="7.5" cy="66.6797" fill="none" rx="4" ry="4" style="stroke:#181818;stroke-width:1.5;"/><polygon fill="#181818" points="75,63.4297,85,67.4297,75,71.4297,79,67.4297" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="12" x2="81" y1="67.4297" y2="67.4297"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="60" x="15" y="62.3638">onLayout</text><line style="stroke:#181818;stroke-width:1.0;" x1="97" x2="144" y1="91.5625" y2="91.5625"/><line style="stroke:#181818;stroke-width:1.0;" x1="144" x2="144" y1="91.5625" y2="104.5625"/><line style="stroke:#181818;stroke-width:1.0;" x1="103" x2="144" y1="104.5625" y2="104.5625"/><polygon fill="#181818" points="113,100.5625,103,104.5625,113,108.5625,109,104.5625" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="98" x="109" y="86.4966">dispatchLayout</text><line style="stroke:#181818;stroke-width:1.0;" x1="102" x2="149" y1="133.6953" y2="133.6953"/><line style="stroke:#181818;stroke-width:1.0;" x1="149" x2="149" y1="133.6953" y2="146.6953"/><line style="stroke:#181818;stroke-width:1.0;" x1="108" x2="149" y1="146.6953" y2="146.6953"/><polygon fill="#181818" points="118,142.6953,108,146.6953,118,150.6953,114,146.6953" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="135" x="114" y="128.6294">dispatchLayoutStep1</text><polygon fill="#181818" points="239,176.8281,249,180.8281,239,184.8281,243,180.8281" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="107" x2="245" y1="180.8281" y2="180.8281"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="112" x="114" y="175.7622">onLayoutChildren</text><polygon fill="#181818" points="469,205.9609,479,209.9609,469,213.9609,473,209.9609" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="261" x2="475" y1="209.9609" y2="209.9609"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="201" x="268" y="204.895">detachAndScrapAttachedViews</text><path d="M27,224.9609 L275,224.9609 L275,232.0938 L265,242.0938 L27,242.0938 L27,224.9609 " fill="#EEEEEE" style="stroke:#000000;stroke-width:1.5;"/><rect fill="none" height="189.9297" style="stroke:#000000;stroke-width:1.5;" width="797" x="27" y="224.9609"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacing" textLength="203" x="42" y="238.0278">&#20498;&#24207;&#36941;&#21382;RecyclerView&#23376;View</text><line style="stroke:#181818;stroke-width:1.0;" x1="491" x2="533" y1="278.3594" y2="278.3594"/><line style="stroke:#181818;stroke-width:1.0;" x1="533" x2="533" y1="278.3594" y2="291.3594"/><line style="stroke:#181818;stroke-width:1.0;" x1="492" x2="533" y1="291.3594" y2="291.3594"/><polygon fill="#181818" points="502,287.3594,492,291.3594,502,295.3594,498,291.3594" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="98" x="498" y="258.1606">ViewHolder&#35774;&#32622;</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="144" x="498" y="273.2935">FLAG_TMP_DETACHED</text><polygon fill="#181818" points="118,316.4922,108,320.4922,118,324.4922,114,320.4922" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="112" x2="480" y1="320.4922" y2="320.4922"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="160" x="124" y="315.4263">detachViewFromParent()</text><polygon fill="#181818" points="637,345.625,647,349.625,637,353.625,641,349.625" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="491" x2="643" y1="349.625" y2="349.625"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="106" x="498" y="344.5591">scrapView(view)</text><line style="stroke:#181818;stroke-width:1.0;" x1="659" x2="701" y1="398.8906" y2="398.8906"/><line style="stroke:#181818;stroke-width:1.0;" x1="701" x2="701" y1="398.8906" y2="411.8906"/><line style="stroke:#181818;stroke-width:1.0;" x1="654" x2="701" y1="411.8906" y2="411.8906"/><polygon fill="#181818" points="664,407.8906,654,411.8906,664,415.8906,660,411.8906" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="111" x="666" y="378.6919">ViewHolder&#28155;&#21152;&#21040;</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="146" x="666" y="393.8247">mAttachedScrap&#21015;&#34920;&#20013;</text><line style="stroke:#181818;stroke-width:1.0;" x1="261" x2="308" y1="438.0234" y2="438.0234"/><line style="stroke:#181818;stroke-width:1.0;" x1="308" x2="308" y1="438.0234" y2="451.0234"/><line style="stroke:#181818;stroke-width:1.0;" x1="267" x2="308" y1="451.0234" y2="451.0234"/><polygon fill="#181818" points="277,447.0234,267,451.0234,277,455.0234,273,451.0234" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="14" x="273" y="432.9575">fill</text><path d="M27,471.0234 L358,471.0234 L358,478.1563 L348,488.1563 L27,488.1563 L27,471.0234 " fill="#EEEEEE" style="stroke:#000000;stroke-width:1.5;"/><rect fill="none" height="335.7266" style="stroke:#000000;stroke-width:1.5;" width="882" x="27" y="471.0234"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacing" textLength="286" x="42" y="484.0903">&#24490;&#29615;&#20174;mAttachedScrap&#21462;&#20986;ViewHouder</text><line style="stroke:#181818;stroke-width:1.0;" x1="266" x2="313" y1="504.2891" y2="504.2891"/><line style="stroke:#181818;stroke-width:1.0;" x1="313" x2="313" y1="504.2891" y2="517.2891"/><line style="stroke:#181818;stroke-width:1.0;" x1="272" x2="313" y1="517.2891" y2="517.2891"/><polygon fill="#181818" points="282,513.2891,272,517.2891,282,521.2891,278,517.2891" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="80" x="278" y="499.2231">layoutChunk</text><polygon fill="#181818" points="637,547.4219,647,551.4219,637,555.4219,641,551.4219" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="271" x2="643" y1="551.4219" y2="551.4219"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="122" x="278" y="546.356">getViewForPosition</text><line style="stroke:#181818;stroke-width:1.0;" x1="659" x2="701" y1="615.8203" y2="615.8203"/><line style="stroke:#181818;stroke-width:1.0;" x1="701" x2="701" y1="615.8203" y2="628.8203"/><line style="stroke:#181818;stroke-width:1.0;" x1="654" x2="701" y1="628.8203" y2="628.8203"/><polygon fill="#181818" points="664,624.8203,654,628.8203,664,632.8203,660,628.8203" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="159" x="666" y="580.4888">&#20174;mAttachedScrap&#21462;&#20986;&#12290;</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="130" x="666" y="595.6216">&#22914;&#26524;&#33719;&#21462;&#19981;&#21040;&#23558;&#20250;&#35843;&#29992;</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="181" x="666" y="610.7544">onCreateViewHolder()&#24182;bind</text><polygon fill="#181818" points="469,648.9531,479,652.9531,469,656.9531,473,652.9531" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="271" x2="475" y1="652.9531" y2="652.9531"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="55" x="278" y="647.8872">addView</text><polygon fill="#181818" points="637,678.0859,647,682.0859,637,686.0859,641,682.0859" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="491" x2="643" y1="682.0859" y2="682.0859"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="92" x="498" y="677.02">unscrapView()</text><line style="stroke:#181818;stroke-width:1.0;" x1="659" x2="701" y1="731.3516" y2="731.3516"/><line style="stroke:#181818;stroke-width:1.0;" x1="701" x2="701" y1="731.3516" y2="744.3516"/><line style="stroke:#181818;stroke-width:1.0;" x1="654" x2="701" y1="744.3516" y2="744.3516"/><polygon fill="#181818" points="664,740.3516,654,744.3516,664,748.3516,660,744.3516" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="231" x="666" y="711.1528">ViewHolder&#20174;mAttachedScrap&#20013;&#21024;&#38500;</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="211" x="666" y="726.2856">mAttachedScrap.remove(holder)</text><polygon fill="#181818" points="118,794.75,108,798.75,118,802.75,114,798.75" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="112" x2="480" y1="798.75" y2="798.75"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="130" x="124" y="763.4185">attachViewToParent</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="280" x="124" y="778.5513">(&#23545;&#20110;onCreateViewHolder&#21019;&#24314;&#30340;&#26032;holder&#23558;&#20250;</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="187" x="124" y="793.6841">&#35843;&#29992;addView&#65292;&#32780;&#19981;&#26159;attache)</text><!--SRC=[dL9DQnD16BxlhvZZXfA2rnw4aBRsa4AmmOiBPTmPay7TcMLsDj9Rh5A3j5ifKjigKa6a26roicrI-sVSIROd_u8psNpiTgs8brrctlTzvlbu7xFYVV0GsnksW_aZWf-3kRa5m6W5Rh1069dAdpeHyJqexCR_zQy9xDqpFCW5iOa7gG0LGZ5FYgkGmZhc0Fh0STmSjBhBS2qtY8CufXcuzD1y7jOrD8e6Ix0G5j1kb2XQipdqIaAVCDB3lb7dBF20REt9tkxDYnqPRgN1vUbR_JC0c08k07spmXo4UNnsFVnnPj7bIkd1UcsrkhwuL2kLLvOMfmCPUHCc-h3CcLk5IfWm2xdk4MjVazMjPbDzTDEqd6uj5jEC1kTz-UPOjhiMTIT2Hwfb-tty-IIwE3KmHGR2q1Qa2GLEkpMswobnd8alrz-6OIVgXxV0TlVbwrxoQg1UrGAo6Cuul80-cnKpykfOZ7nWlCfy8WYZVrDu1uMVhKsBog-RWqyVu_1StKKNEqgyx6v5LqTnz-NmtOb56IrphAJEN38BylBx4wACc15FU4E4Ce5dA0Tqbia_vf7ZhHAGxUERmo-t0vhds6LDR3P6SuMxDWYAoGRLMB8_5ZLbvpBgXNcTilr1zdl3erU3_Mw2cpXZqSIRiTfVLzjnQrjPDpZe9FYueDVaDm00]--></g></svg>

<h2 id="从缓存获取ViewHolder"><a href="#从缓存获取ViewHolder" class="headerlink" title="从缓存获取ViewHolder"></a>从缓存获取ViewHolder</h2><p>首次创建ViewHolder，以及从缓存中获取都是通过<code>androidx.recyclerview.widget.RecyclerView.Recycler#getViewForPosition(int)</code>，这个方法会优先使用缓存中ViewHolder，如果找不到，就会调用createViewHolder和bindViewHolder创建一个新的，并返回ViewHodler的itemView：</p>
<p><img src="/images/RecyclerView/RecyclerView%E6%9F%A5%E6%89%BE%E7%BC%93%E5%AD%98%E6%B5%81%E7%A8%8B%E5%9B%BE.drawio.svg" alt="ViewHolder查找创建流程"></p>
<h2 id="ItemAnimator"><a href="#ItemAnimator" class="headerlink" title="ItemAnimator"></a>ItemAnimator</h2><?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="265px" preserveAspectRatio="none" style="width:809px;height:265px;background:#FFFFFF;" version="1.1" viewBox="0 0 809 265" width="809px" zoomAndPan="magnify"><defs/><g><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="167" x2="167" y1="36.2969" y2="230.0938"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="320" x2="320" y1="36.2969" y2="230.0938"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="577.5" x2="577.5" y1="36.2969" y2="230.0938"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="745.5" x2="745.5" y1="36.2969" y2="230.0938"/><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="110" x="112" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="96" x="119" y="24.9951">RecyclerView</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="110" x="112" y="229.0938"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="96" x="119" y="249.0889">RecyclerView</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="48" x="296" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="34" x="303" y="24.9951">View</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="48" x="296" y="229.0938"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="34" x="303" y="249.0889">View</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="123" x="516.5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="109" x="523.5" y="24.9951">Choreographer</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="123" x="516.5" y="229.0938"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="109" x="523.5" y="249.0889">Choreographer</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="115" x="688.5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="101" x="695.5" y="24.9951">ItemAnimator</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="115" x="688.5" y="229.0938"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="101" x="695.5" y="249.0889">ItemAnimator</text><ellipse cx="7.5" cy="66.6797" fill="none" rx="4" ry="4" style="stroke:#181818;stroke-width:1.5;"/><polygon fill="#181818" points="155,63.4297,165,67.4297,155,71.4297,159,67.4297" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="12" x2="161" y1="67.4297" y2="67.4297"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="135" x="15" y="62.3638">dispatchLayoutStep3</text><line style="stroke:#181818;stroke-width:1.0;" x1="167" x2="209" y1="96.5625" y2="96.5625"/><line style="stroke:#181818;stroke-width:1.0;" x1="209" x2="209" y1="96.5625" y2="109.5625"/><line style="stroke:#181818;stroke-width:1.0;" x1="168" x2="209" y1="109.5625" y2="109.5625"/><polygon fill="#181818" points="178,105.5625,168,109.5625,178,113.5625,174,109.5625" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="139" x="174" y="91.4966">postAnimationRunner</text><polygon fill="#181818" points="308,134.6953,318,138.6953,308,142.6953,312,138.6953" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="167" x2="314" y1="138.6953" y2="138.6953"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="111" x="174" y="133.6294">postOnAnimation</text><polygon fill="#181818" points="566,163.8281,576,167.8281,566,171.8281,570,167.8281" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="320" x2="572" y1="167.8281" y2="167.8281"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="234" x="327" y="162.7622">postCallback(CALLBACK_ANIMATION)</text><polygon fill="#181818" points="734,208.0938,744,212.0938,734,216.0938,738,212.0938" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" x1="578" x2="740" y1="212.0938" y2="212.0938"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="144" x="585" y="191.895">runPendingAnimations</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="90" x="585" y="207.0278">callback&#20013;&#35843;&#29992;</text><!--SRC=[YyxNjLC8IaskJCv9BGhBJ2rNi598oImkI2n9pl19hCmlBGakIIqmva9HWgcb8B-un34lCpUn93C_BwWqBo-r24CBabB_FBXYBfYqSqP-KMf-Ub5YGKPg4LITSs9EJb9YShQ6iwEFZvEZitUyev-dhsE8fx-V9XUg1bsW4PubgRaGW_D19XILvWMavgLavgN3RIkEoKk6clbanzeN6vgVJra10000]--></g></svg>

    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/Android/" rel="tag"># Android</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/posts/2230f1f1.html" rel="prev" title="Java float和double存储结构">
                  <i class="fa fa-angle-left"></i> Java float和double存储结构
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/posts/d01e7370.html" rel="next" title="Android View Measure源码分析">
                  Android View Measure源码分析 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 
    <span itemprop="copyrightYear">2024</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">Jason</span>
  </div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener external nofollow noreferrer" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/pisces/" rel="noopener external nofollow noreferrer" target="_blank">NexT.Pisces</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.24/fancybox/fancybox.umd.js" integrity="sha256-oyhjPiYRWGXaAt+ny/mTMWOnN1GBoZDUQnzzgC7FRI4=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>


  <script class="next-config" data-name="mermaid" type="application/json">{"enable":true,"theme":{"light":"default","dark":"dark"},"js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.5.0/mermaid.min.js","integrity":"sha256-K7oJiQlDulzl24ZUFOywuYme1JqBBvQzK6m8qHjt9Gk="}}</script>
  <script type="module" src="/js/zenuml-definition-074a43fa.js"></script>
  <script type="module" src="/js/mermaid-zenuml.esm.min.mjs"></script>
  <script src="/js/third-party/tags/mermaid.js"></script>


  <script src="/js/third-party/fancybox.js"></script>



  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>



</body>
</html>
